subroutine readrctn(lunit,t_array0,myrank)
  use param
  use data_param,only:rtfn
  use data_param,only:n_react_data
  use data_param,only:react_exist
  use react_data_param,only:n_react_type
  use react_data_param,only:react_map
  use react_data_param,only:react_type
  implicit none

  interface
     function reallocReactType(p,n)
       use derived
       type(ReactionType),pointer,dimension(:) :: &
            reallocReactType,p
       integer,intent(in) :: n
     end function reallocReactType

     function reallocReal(p,n)
       use param
       real(dbl),pointer,dimension(:) :: reallocReal,p
       integer,intent(in) :: n
     end function reallocReal

     function reallocInt(p,n)
       integer,pointer,dimension(:) :: reallocInt,p
       integer,intent(in) :: n
     end function reallocInt

     integer function str2label(str)
       character :: str*(*)
     end function str2label

     function reallocProductType(p,n,q)
       use derived
       type(ProductType),pointer,dimension(:) :: &
            reallocProductType,p
       integer,intent(in) :: n,q
     end function reallocProductType
  end interface

  integer,intent(in) :: lunit,t_array0(8),myrank

  integer :: nunit,count_line,len_str,asci_code
  character(len=len_linebuf) :: eatline
  character(len=len_wordbuf),dimension(max_n_word) :: eatword
  character(len=8) :: d_time_str

  integer :: i
  integer :: r1,r2,rm,nr,nd,np

  if (.not.react_exist) return

  nunit=1

  open(unit=1,file=rtfn,status='old',err=103)

  count_line=0
  nr=0
  do
     read(nunit,'(a)',end=100,err=101) eatline
     count_line=count_line+1
     len_str=len_trim(eatline)
     if (len_str.eq.0) cycle
     eatline=adjustl(eatline)
     asci_code=ichar(eatline(1:1))
     if (asci_code.eq.ccode) cycle
     read(eatline(1:len_str),*,end=102) &
          (eatword(i),i=1,max_n_word)
102  continue
     ! c1:reactant1
     ! c2:reactant2
     ! c3:energy barrier
     ! c4:prefactor
     ! c5:interaction distance
     ! c6:number of products
     ! c7-:types of products

     r1=str2label(eatword(1))
     r2=str2label(eatword(2))

     if (r1.eq.0.or.r2.eq.0) then
        call terminal_msg2("line-",&
             trim(adjustl(eatline)))
        call abnormal_stop("readrctn",&
             "Unrecognized label is found in the reaction data.")
     end if

     ! Count the number of data
     n_react_data=n_react_data+1

     ! Check if the reactions exist for r1 and r2
     rm=react_map(r1,r2)
     if (rm.eq.0) then
        ! New reaction type
        nr=nr+1
        n_react_type=nr
        react_type=>reallocReactType(react_type,nr)
        react_map(r1,r2)=nr
        react_map(r2,r1)=nr
        react_type(nr)%obj1=r1
        react_type(nr)%obj2=r2
        react_type(nr)%n_data=1
        rm=nr
     else
        ! Old reaction type
        react_type(rm)%n_data=&
             react_type(rm)%n_data+1
     end if

     ! Number of data in this reaction type
     nd=react_type(rm)%n_data

     ! Re-allocate the arrays for reaction data
     react_type(rm)%react_eb=>reallocReal(&
          react_type(rm)%react_eb,nd)
     react_type(rm)%react_nu=>reallocReal(&
          react_type(rm)%react_nu,nd)
     react_type(rm)%react_rd=>reallocReal(&
          react_type(rm)%react_rd,nd)
     react_type(rm)%react_rd2=>reallocReal(&
          react_type(rm)%react_rd2,nd)
     react_type(rm)%react_const_rate=>reallocReal(&
          react_type(rm)%react_const_rate,nd)
     react_type(rm)%n_new=>reallocInt(&
          react_type(rm)%n_new,nd)
     react_type(rm)%new=>reallocProductType(&
          react_type(rm)%new,nd,rm)

     ! Read the data
     read(eatword(3),*) react_type(rm)%react_eb(nd)
     read(eatword(4),*) react_type(rm)%react_nu(nd)
     read(eatword(5),*) react_type(rm)%react_rd(nd)
     react_type(rm)%react_rd2(nd)=&
          react_type(rm)%react_rd(nd)*&
          react_type(rm)%react_rd(nd)
     read(eatword(6),*) react_type(rm)%n_new(nd)
     react_type(rm)%react_const_rate(nd)=0

     np=react_type(rm)%n_new(nd)

     ! Annihilation
     if (np.eq.0) cycle

     ! Types of reactants
     allocate(react_type(rm)%new(nd)%prod_type(np))
     
     do i=1,np
        r1=str2label(eatword(6+i))
        if (r1.eq.0) then
           call terminal_msg2("line",trim(adjustl(eatline)))
           call abnormal_stop("readrctn",&
                "Unrecognized label is found in reaction data.")
        end if
        react_type(rm)%new(nd)%prod_type(i)=r1
     end do

  end do

103 continue
  call abnormal_stop("readrctn",&
       "Error occurs while the rctn file opens.")

101 continue
  call abnormal_stop("readrctn",&
       "Error occurs during reading the reaction file.")

100 continue

  close(nunit)

  ! Print the label file info.
  call log_msg1(lunit,"")
  call log_msg1(lunit,"Message from the subourinte (readrctn)")
  call log_msg1(lunit,"")
  write(lunit,'(1x,i0,1x,"lines read from the ",a)') &
       count_line,trim(rtfn)
  write(lunit,'(1x,"Number of types for reactions=",1x,i0)') &
       n_react_type

  ! Write the message to the terminal and log file
  call print_d_time(t_array0,d_time_str)
  if (myrank.eq.0) &
       write(*,'(a8,":READRCTN DONE.")') d_time_str(1:8)
  write(lunit,*)
  write(lunit,'(a8,":READRCTN DONE.")') d_time_str(1:8)

  return

end subroutine readrctn
